package com.usermanage.controller;

import com.usermanage.Service.LogisticsService;
import com.usermanage.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/wuliu")
public class WuLiuController {

    @Resource
    private LogisticsService logisticsService;

    @RequestMapping("/query.json")
    public String getWuLiuMessage(String no) throws Exception {
        String result = logisticsService.getOrderTracesByJson(no);
        Map map = StringUtil.JsonToMap(result);
        List<Map> list = StringUtil.JsonToList(StringUtil.ObjectToJson(map.get("Shippers")));
       return logisticsService.getOrderTracesByJson(list.get(0).get("ShipperCode").toString(),no);
    }
}
